package entities;

import java.util.ArrayList;

/**
 * Entity Class for Trainings. A Training is an Event and can be a normal or
 * stamina training.
 * 
 * @author MK
 * @see entities.Event
 * 
 */
public class Training extends Event {

	private String type;

	public Training() {
		super();
	}

	public Training(Long date, Address place,
			ArrayList<Participant> participants, String type) {
		super(date, place, participants);
		this.type = type;
	}

	public Training(Training training) {
		this(training.date, training.place, training.participants,
				training.type);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Training other = (Training) obj;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Training [type=" + type + ", date=" + date + ", participants="
				+ participants + ", place=" + place + "]";
	}

	public int compareTo(Training training) {

		if (super.compareTo((Event) training) != 0) {
			return super.compareTo((Event) training);
		} else {
			return this.type.compareTo(training.type);
		}
	}

	public String getType() {
		return type;
	}
}